import Immutable from 'seamless-immutable';
import * as types from '../constants/ActionTypes';

const testCategory = Immutable.from({
  testCategoryList: {},
  oneCategoryData: {},
  pushCategoryLog: {},
  saveMsg: {}
});
export default function testCategoryReducer(state = testCategory, action) {
  const { payload, type } = action;
  switch (type) {
    case types.FETCH_TEST_CATEGORY:
      return state.setIn(['testCategoryList'], payload);
    case types.FETCH_PUSH_CATEGORY_LOG:
      return state.setIn(['pushCategoryLog'], payload);
    case types.GET_ONE_CATEGORY:
      return state.setIn(['oneCategoryData'], payload);
    case types.RESTORE_TEST_CATEGORY:
      return state.setIn(['testCategoryList'], {});
    case types.SAVE_TEST_CATEGORY_ERROR_MSG:
      return state.setIn(['saveMsg'], payload);
    default:
      return state;
  }
}
